//
//  NewsTableViewCell.m
//  网易
//
//  Created by Roach on 16/6/22.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "NewsTableViewCell.h"
#import "NewsModel.h"
#import "GatHeightTools.h"

@interface NewsTableViewCell ()

@property (nonatomic, retain) UILabel *label;

@end

@implementation NewsTableViewCell

- (void)dealloc {
    
    [_newsCellModel release];
    [super dealloc];
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.label = [[UILabel alloc]init];
        [self.contentView addSubview:_label];
        [_label release];
    }
    
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    CGFloat height = [GatHeightTools heightWith:self.newsCellModel.digest];
    
    self.label.frame = CGRectMake(20, 20, self.contentView.bounds.size.width - 30, height);
    
    self.label.numberOfLines = 0;
    
}

- (void)setNewsCellModel:(NewsModel *)newsCellModel{
    
    if (_newsCellModel != newsCellModel) {
        [_newsCellModel release];
        _newsCellModel = [newsCellModel retain];
    }
    
    self.label.text = newsCellModel.digest;
    
}

@end
